package com.manjusaka.structure7.Decorator;

/**
 * Created by manjusaka on 2017/7/5.
 */
public class DecoratorPattern {
    public static void main(String[] args) {
        Window Window=new Window();
        Frame frame = new Frame(Window);
        frame.disPlay();
    }
}

abstract class Component {
    abstract void disPlay();
}

class Window extends Component {
    public void disPlay() {
        System.out.println("显示窗体");
    }
}

class ComponentDecorator extends Component {
    private Component Component;

    public ComponentDecorator(Component Component) {
        this.Component = Component;
    }

    public void disPlay() {
        Component.disPlay();
    }
}

/**
 * 需要装饰的框架
 */
class Frame extends ComponentDecorator {
    public Frame(Component Component) {
        super(Component);
    }

    public void disPlay() {
        disPlayFrame();
        super.disPlay();
    }

    public void disPlayFrame() {
        System.out.println("显示边框");
    }
}

/**
 * 需要装饰的标题
 */
class Title extends ComponentDecorator {
    public Title(Component Component) {
        super(Component);
    }

    public void disPlay() {
        disPlayTitle();
        super.disPlay();
    }

    public void disPlayTitle() {
        System.out.println("显示标题");
    }
}
